class JinLiang:

    def __init__(self, jin=0, liang=0):
        ''' init the instance '''
        self.value = jin*16+liang

    def __str__(self):
        ''' convert to string '''
        return str(self.value//16)+"斤"+str(self.value%16)+"两"
    
    def __eq__(self,other):
        return self.value == other.value

    def __ne__(self,other):
        '''not equal'''
        return self.value != other.value

    def __lt__(self,other):
        '''less than'''
        return self.value < other.value

    def __le__(self,other):
        '''less than or equal'''
        return self.value <= other.value

    def __gt__(self,other):
        '''greater than'''
        return self.value > other.value

    def __ge__(self,other):
        '''greater than or equal'''
        return self.value >= other.value

    def __add__(self,other):
        ''' add an instance to self '''
        a = self.value + other.value
        return JinLiang(a//16,a%16)

    def __sub__(self,other):
        ''' get distance of two instances '''
        a = abs(self.value - other.value)
        return JinLiang(a//16,a%16)


# === DO NOT modify the code below ===
def main():
    j1 = JinLiang(3,8)
    j2 = JinLiang(2,9)
    assert j1 > j2
    assert j1 + j2 == JinLiang(6,1)
    assert j1 - j2 == JinLiang(0,15)
    assert j2 - j1 == JinLiang(0,15)
    assert str(j1+j2) == '6斤1两'    
    print("Congratulations! All tests are passed!")

if __name__=="__main__":
    main()
# === DO NOT modify the code above ===

